package com.team.teamproject.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.picasso.Picasso;
import com.team.teamproject.R;
import com.team.teamproject.bean.HotRecommend;
import com.team.teamproject.bean.hotitems;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/8.
 */

public class HotRecommendAdapter extends BaseAdapter{
    //private String recommendname,recommendprice,image_url;
   // private List<String> lists=new ArrayList<>();
    private List<String> recommendnamelist,recommendpricelist,image_urllist;
    private Context context;
    public HotRecommendAdapter(Context context,List<String> recommendnamelist,List<String> recommendpricelist,List<String> image_urllist){
        this.context=context;
        this.recommendnamelist=recommendnamelist;
        this.recommendpricelist=recommendpricelist;
        this.image_urllist=image_urllist;

    }
    @Override
    public int getCount() {

        return recommendnamelist.size();
    }

    @Override
    public Object getItem(int position) {
        return recommendnamelist.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null)
        {
            holder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.adapter_firsthot,null);
            holder.cv_iv= (ImageView) convertView.findViewById(R.id.cv_iv);
            holder.cv_tv_name= (TextView) convertView.findViewById(R.id.cv_tv_name);
            holder.cv_tv_price= (TextView) convertView.findViewById(R.id.cv_tv_price);
            convertView.setTag(holder);
        }
        else
        {
            holder= (ViewHolder) convertView.getTag();
        }
       holder.cv_tv_name.setText(recommendnamelist.get(position));
        holder.cv_tv_price.setText(recommendpricelist.get(position));
        Picasso.with(context).load(image_urllist.get(position)).into(holder.cv_iv);


        return convertView;
    }
    public class ViewHolder{
        ImageView cv_iv;
        TextView cv_tv_name,cv_tv_price;
    }
}
